package com.easy.controller;

import com.easy.bean.Cart;
import com.easy.bean.Collect;
import com.easy.service.ICartService;
import com.easy.service.ICollectService;
import com.easy.util.LayData;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("collect")
public class CollectController {
    @Autowired
    ICollectService collectService;


    @RequestMapping("list")
    @ResponseBody
    public LayData getList(Page page, String text){
        List<Collect> list=collectService.getList(page,text);
        int count=collectService.getCount(text);
        return new LayData(count,list);
    }
    @RequestMapping("delete")
    @ResponseBody
    public int delete(int id){
        return collectService.delete(id);
    }

    @RequestMapping("add")
    @ResponseBody
    public int add(Collect collect){
        return collectService.add(collect);
    }

    @RequestMapping("edit")
    @ResponseBody
    public int edit(Collect collect){
        return collectService.edit(collect);
    }
}
